<?php

class upload {
    function getFullFileName ($filename) {
        return $filepath = '/public/files' . $filename;
    }
    function up($form_name) {
        $file1 = $_FILES[$form_name];
        
        $result = array();
        $result['error'] = 0;
        $result['path'] = '';
        
        if($file1['error'] > 0){
            $result['error'] = $file1['error'];
            return $result;
        }
        $ext = strtolower(pathinfo($file1['name'],PATHINFO_EXTENSION));
        
        $filename = microtime(true).".".$ext;
        $result['filename'] = $filename;
        $result['full_filename'] = $this->getFullFileName($filename);
        $result['disk_filename'] = APP_PATH . $result['full_filename'];
        var_dump($result);
        $is = move_uploaded_file($file1['tmp_name'], $result['disk_filename']);
        if(!$is){
            $result['error'] = -1;
        }
        var_dump($is);
        return $result;
        
        
    }
}
